package felix.actor.core;

import felix.actor.core.msg.TActorMsg;

public interface TActor {

    boolean process(TActorMsg msg);

    TActorRef getActorRef();

    default void init(TActorCtx ctx) throws TActorException {
    }

    default void destroy() throws TActorException {
    }

    default InitFailureStrategy onInitFailure(int attempt, Throwable t) {
        return InitFailureStrategy.retryWithDelay(5000 * attempt);
    }

    default ProcessFailureStrategy onProcessFailure(Throwable t) {
        if (t instanceof Error) {
            return ProcessFailureStrategy.stop();
        } else {
            return ProcessFailureStrategy.resume();
        }
    }
}
